Subject: cloning file handles (was: Re: SystemTagList() Problems)
From: [email-masked] (Arno Eigenwillig)
Date: Tue, 17 May 1994 15:34:31 +0100
Newsgroups: comp.sys.amiga.programmer

Hi!

In article <[email-masked]>, Ralf writes:

> BPTR DupFH(BPTR oldfh)		/* never pass an exclusive fh */
> {
> BPTR lock,fh;
> 
> if (lock=DupLockFromFH(oldfh))
> 	{
> 	if (fh=OpenFromLock(lock))	/* this does really only take 1 parm */
> 		return fh;
> 	UnLock(lock);
> 	}
> return 0;
> }

The above code should be perfect for usual file system files. However,
as the original subject - SystemTagList() problems - brings back to
mind, the original intention was to clone the current input and output
file handles. And these are not guaranteed to be files from which a
lock can be DupLockFromFH()'ed:
- they may be non - file system "files" (such as a console or a pipe)
- they may be files on a file system not supporting the underlying
  ACTION_COPY_DIR_FH packet

For interactive "files" there is the way Ralph Babel demonstrates in
his Guru Book:

	pr = (struct Process *)FindTask(0);
	oldcontask = pr->pr_ConsoleTask;
	pr->pr_ConsoleTask = <another handler's process ID>;
	fh = Open("*", MODE_NEWFILE);
	pr->pr_ConsoleTask = oldcontask;

Similarities to Ralph's ConWindowC.c are admittedly not conincidential.

However, I still hold up the statement I made in <[email-masked]>:

> there is no general way to clone file handles

Sad.

-- __
__/// Arno Eigenwillig <[email-masked]>
\XX/  MIME & PGP supported * V:+49-2225-5870 

Every real programmer knows that 0x2b | ~0x2b == -1.